<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function idenitify(num){
    return num<10?"0"+num:num;
   }
   function creatTimer(){
    var date1 = new Date();
    var year = date1.getFullYear();
    var month = date1.getMonth()+1;
    var day = date1.getDate();
    var hour = date1.getHours();
    var minute = date1.getMinutes();
    var second = date1.getSeconds();
    month = idenitify(month);
    day = idenitify(day);
    hour = idenitify(hour);
    minute = idenitify(minute);
    second = idenitify(second);
    var result = year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
    return result;
}
 var timeId = setInterval(function() {
       
        document.write("当前的时间为："+creatTimer()+"<br/>");
    }, 1000);
</script>
</html>